﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ex04
{
    class Program
    {
        static void Main(string[] args)
        {
            var db = new NorthwindDataContext();
            // If we simply enumerate without projecting, then LINQ to SQL round-trips
            // on each EntitySet (look at the SQL results pane).
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            foreach (Customer c in db.Customers)
                foreach (Purchase p in c.Purchases)    // Another SQL round-trip
                    Console.WriteLine(c.Name + " spent " + p.Price);
            stopwatch.Stop();
            Console.WriteLine(stopwatch.ElapsedMilliseconds);
            Console.ReadKey();
        }
    }
}
